package com.yxw.live_vod_boot.controller;

import com.yxw.live_vod_boot.dto.VideoReviewDeleteDTO;
import com.yxw.live_vod_boot.service.OnDemandVideoReviewService;
import com.yxw.live_vod_facade.dto.PageVideoReviewsDTO;
import com.yxw.live_vod_facade.dto.VideoReviewHandelDTO;
import com.yxw.live_vod_facade.vo.VideoReviewVO;
import com.yxw.yxnet_cd_center.common.dto.PageVO;
import com.yxw.yxnet_cd_center.common.enums.ErrorCodeEnum;
import com.yxw.yxnet_cd_center.common.helper.ResultHelper;
import com.yxw.yxnet_cd_center.common.utils.BaseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 点播视频审核管理
 * @author liuxin
 * @date 2023.11.15
 */
@RestController
@Api(value = "点播视频审核管理", tags = "点播视频审核管理")
@Slf4j
@RequestMapping("/api/onDemand/review")
public class OnDemandVideoReviewController {

    @Autowired
    private OnDemandVideoReviewService onDemandVideoReviewService;

    @PostMapping(value = "/handle")
    @ApiOperation(value = "视频审核处理")
    public BaseResult handle(@RequestBody @Validated VideoReviewHandelDTO dto){
        try{
            onDemandVideoReviewService.handle(dto);
            return BaseResult.doSuccess(null,"审核成功");
        }catch (Exception e){
            return BaseResult.failed(ErrorCodeEnum.UNKNOWN_ERROR,e.getMessage());
        }
    }

    @ApiOperation(value = "查询待审核视频列表")
    @PostMapping(value = "/pageVideoReviews")
    public BaseResult<PageVO<VideoReviewVO>> pageVideoReviews(@RequestBody @Validated PageVideoReviewsDTO dto){
        PageVO<VideoReviewVO> voList=onDemandVideoReviewService.pageVideoReviews(dto);
        return ResultHelper.fillWithSuccess(voList);
    }
    @ApiOperation(value = "审核视频删除")
    @PostMapping(value = "/deleteVideoReviewByIds")
    public BaseResult deleteVideoReviewByIds(@RequestBody @Validated VideoReviewDeleteDTO dto){
        onDemandVideoReviewService.deleteVideoReviewByIds(dto);
        return BaseResult.doSuccess(null,"删除成功");
    }

    @ApiOperation(value = "根据id查询审核详情")
    @GetMapping(value = "/getVideoReviewById")
    public BaseResult getVideoReviewById(@RequestParam Long reviewVideoId){
        VideoReviewVO vo =onDemandVideoReviewService.getVideoReviewById(reviewVideoId);
        return BaseResult.doSuccess(vo,"查询成功");
    }
}
